#!/usr/bin/python
#Needs 2 files
#1: tab file (annotations)
#2: coordinates file (alien hunter identified genomic coords)
import sys

tab_file = sys.argv[1]
tf = open(tab_file, "rU")
lines = tf.readlines()

ah_file = sys.argv[2]
af = open(ah_file, "rU")
alines = af.readlines()

astarts = []
astops = []

for line in alines:
    l = line.split('\t')
    astarts.append(int(l[0]))
    astops.append(int(l[1].rstrip()))

num = len(astarts)

for line in lines:
    l = line.split('\t')
    locus = l[1] 
    start = int(l[2])
    stop = int(l[3])
    desc = l[10].rstrip()
    i = 0
    while i < num:
        if astarts[i] < start < astops[i] and astarts[i] < stop < astops[i]:
            print "Genomic Island " + str(i+1) + "(" + str(astarts[i]) + "_" + str(astops[i]) + ")" + \
                "\t" + locus + "\t" + str(start) + "\t" + str(stop) + "\t" + desc
        i += 1

tf.close()
af.close()
